package com.ferry.taskflow.taskFlow.base;


import com.ferry.taskflow.taskFlow.base.enumv.TaskState;
import com.ferry.taskflow.taskFlow.domain.TaskResult;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by daiyong
 */
public abstract class TaskExecutor<RESULT> {

	/**
	 * 关联任务 事务/非事务 任务
	 */
	protected Task<RESULT> task;

	/**
	 * 任务执行结果
	 */
	protected TaskResult taskResult = new TaskResult(false, false, null);

	/**
	 * 任务状态
	 */
	protected AtomicInteger state = new AtomicInteger(TaskState.INIT.getCode());


	public TaskExecutor(Task<RESULT> task) {
		this.task = task;
	}

	protected int getState() {
		return state.get();
	}

	/**
	 * 执行逻辑包装
	 */
	public abstract void execute();

}
